﻿using System;
using System.Windows.Data;
using FlashCards.SL.FlashCardCreator.ViewModels.Utils;
using System.Windows;

namespace FlashCards.SL.FlashCardCreator.Converters
{
    public class ContentViewModelToVisibility : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var viewModel = value as IContentViewModel;
            var stringParam = parameter as string;
            if (viewModel != null && !string.IsNullOrEmpty(stringParam))
            {
                if (stringParam == "Text")
                {
                    if (viewModel is TextContentViewModel)
                        return Visibility.Visible;
                    else
                        return Visibility.Collapsed;
                }
                else if (stringParam == "Image")
                {
                    return Visibility.Collapsed;
                }
            }

            return Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
